﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Text;
using System.Data;



public partial class MessageBoard : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Add the new connection string to the web.config
            StringBuilder strSql = new StringBuilder();

            try
            {
                strSql.AppendLine(" select top 1 message ");
                strSql.AppendLine("  from dbo.message ");             //网络教学资料

                TextBox2.Text = (String)SqlHelper.ExecuteScalar(SqlHelper.ConnectionString, System.Data.CommandType.Text, strSql.ToString());
            }
            catch (Exception ex)
            {
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

        StringBuilder strSql = new StringBuilder();
        try
        {
            strSql.AppendLine("update dbo.message ");
            strSql.AppendLine(" set message = @message");
 
            SqlParameter[] _parms = {
                new SqlParameter("@message",SqlDbType.NVarChar)};

            _parms[0].Value = TextBox2.Text;
            int iResust = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, strSql.ToString(), _parms);
        }
        catch (Exception ex)
        {
        }

    }
}